import pandas as pd


def convert_csv(tsv_dir):
    # reading given tsv file
    csv_table = pd.read_table(tsv_dir)
    # converting tsv file into csv
    csv_table.to_csv('cc12m.csv', index=False)
    # output
    print("Successfully made csv file")


def split_csv(csv_file):
    data = pd.read_csv(csv_file)
    for i in range(0, 10):
        save_data = data.iloc[i * 10 + 1: (i + 1) * 10 + 1]
        file_name = r'../cc12m1/cc12m_split_' + str(i) + '.csv'  # 保存文件路径以及文件名称
        save_data.to_csv(file_name, index=False)  # 保存格式为.csv，如果是xlsx则修改为save_data.to_excel
    print("success")


if __name__ == '__main__':
    tsv_file_path = '/path/to/cc12m.tsv'
    convert_csv(tsv_file_path)


